package com.yyyzzz.servlet;

import com.yyyzzz.bean.Course;
import com.yyyzzz.bean.Student;
import com.yyyzzz.service.courseService;
import com.yyyzzz.service.impl.courseServiceimpl;
import com.yyyzzz.service.impl.studentServiceimpl;
import com.yyyzzz.service.studentService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@WebServlet("/updateStudentServlet")
public class updateStudentServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        String stuno = request.getParameter("stuNo");
        String stuname = request.getParameter("stuName");
        String stuclass = request.getParameter("stuClass");
        String stumajor = request.getParameter("stuMajor");
        String stuemail = request.getParameter("stuEmail");
        String stutelphone = request.getParameter("stutelphone");
        response.setCharacterEncoding("utf-8");


        Student student = new Student();
        student.setStuNo(stuno);
        student.setStuName(stuname);
        student.setStuClass(stuclass);
        student.setStuMajor(stumajor);
        student.setStuEmail(stuemail);
        student.setStutelphone(stutelphone);
        studentServiceimpl service = new studentServiceimpl();
        boolean update = service.updateStudent(student);
        if(update==true){
            request.getRequestDispatcher("studentMain.jsp").forward(request,response);
        }else{
            request.getRequestDispatcher("updateError.jsp").forward(request,response);
        }

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
